******************************************************************
* Replication Code for "The Puzzle of Militia Containment" (ISQ) *
* Brandon Bolte                                                  *
* 12/11/20                                                       *
******************************************************************
clear
cd "C:\Users\brand\Desktop\PGM_ISQ_Final_Files\Replication_Materials"


use "PGM_ISQmain.dta"

*** Main: Table 1 ***
logit cnew1plus logtroop rpr, cluster(war_id)
logit cnew2plus logtroop rpr, cluster(war_id)

logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership, cluster(war_id)

logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3, cluster(war_id)
pre
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3, cluster(war_id)
pre

*** Figures: see R-script ***

*** Appendix ***

** Table 1: Summary Statistics **
sum containment1new logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3, det

** Table 2: Correlation Matrix **
cor logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3

** Table 3: Multinomial Logit- De Jure and De Facto **
mlogit containment1new semiofficial, base(1) vce(cluster war_id)

** Table 4: Bivariate Results and Orginal Logits **
logit cnew1plus logtroop, cluster(war_id)
logit cnew2plus logtroop, cluster(war_id)
logit cnew1plus rpr, cluster(war_id)
logit cnew2plus rpr, cluster(war_id)

ologit containment1new logtroop rpr, cluster(war_id)
brant, detail
ologit containment1new logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership, cluster(war_id)
brant, detail
ologit containment1new logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3, cluster(war_id)
brant, detail

** Table 5: Ordered Binary Logits- Additional Controls **
logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership foreignsupp, cluster(war_id)
logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 foreignsupp, cluster(war_id)

logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership logbdeath duration guerrilla, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership logbdeath duration guerrilla, cluster(war_id)

logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 logbdeath duration guerrilla, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 logbdeath duration guerrilla, cluster(war_id)

** Table 6: Multinomial Logistic Regressions **
mlogit containment1new logtroop rpr, base(2) vce(cluster war_id)
mlogit containment1new logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership, base(2) vce(cluster war_id)
mlogit containment1new logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3, base(2) vce(cluster war_id)

** Table 7: Endogeneity probe **
clear 
use "civtargeting.dta"
logit miltargeting containment

clear 
use "PGM_ISQmain.dta"

logit cnew1plus logtroop rpraltalt shared_ethnic criminal peasant semiofficial jointmembership , cluster(war_id)
logit cnew2plus logtroop rpraltalt shared_ethnic criminal peasant  semiofficial jointmembership, cluster(war_id)

logit cnew1plus logtroop rpraltalt shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 , cluster(war_id)
logit cnew2plus logtroop rpraltalt shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 , cluster(war_id)

** Table 8: Ordered Binary Logits- Militias Formed During War **

logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership formed, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership formed, cluster(war_id)
logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 formed, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 formed, cluster(war_id)
logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership if formed==1, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership if formed==1, cluster(war_id)
logit cnew1plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 if formed==1, cluster(war_id)
logit cnew2plus logtroop rpr shared_ethnic criminal peasant semiofficial jointmembership contigwar lngdpcapnew separatist polity num_militias3 if formed==1, cluster(war_id)

** Table 9: Cox Model **
clear 

use "survivaldata_public.dta"

stset survivaltime, id(pgm_id) failure(dissolve)
stcox rpr containment1new if war==0, vce(cluster cowcode) nohr 
stcox rpr containment1new rprcont3 if war==0, vce(cluster cowcode) nohr 

lincom(_b[rpr]+_b[rprcont3]*1)
lincom(_b[rpr]+_b[rprcont3]*2)
lincom(_b[rpr]+_b[rprcont3]*3)


** See R-script for all figures **


















